package net.skyedu.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import net.skyedu.bean.OAUser;

public class OASuper extends OADao{
	private Connection conn = null;
	private PreparedStatement pstmt = null;
	private ResultSet rs = null;
	
	public OAUser getEmployee(String name){
		OAUser user=null;
		try{
			StringBuffer sql=new StringBuffer("select s.*,d.name da ,sch.name schname from sys_employee s,sys_dept d ,sys_school sch where s.dept_id=d.id and sch.id=s.school_id and s.name='"+name+"'");
			
			conn=this.getConn();
			pstmt=conn.prepareStatement(sql.toString());
			rs=pstmt.executeQuery();
			while(rs.next()){
				user = new OAUser();
				user.setId(rs.getInt("id"));
				user.setPostId(rs.getInt("post_id"));
				user.setStatus(rs.getInt("status"));
				user.setDeptName(rs.getString("da"));
				user.setSchoolname(rs.getString("schname"));
			}
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			this.closeAll(conn, pstmt, rs);
		}
		return user;
	}
//	public static void main(String[] args) {
//		OASuper os=new OASuper();
//		OAUser oa=os.getEmployee("谢宗洪");
//		System.out.println(oa.getDeptName()+oa.getPostId()+oa.getId());
//	}
//	public static void main(String[] args) {
//		String str="����ѡ";
//		Pattern pattern = Pattern.compile("[0-9]{1,}");
//		  Matcher matcher = pattern.matcher((CharSequence)str);
//		  boolean result = matcher.matches();
//		  if (result == true) {
//		   System.out.println("yes");
//		  }else{
//		   System.out.println("no");
//		  }
//	}
}
